<?php
class Article extends CActiveRecord
{
	public static function model($className = __CLASS__)
	{
		return parent::model($className);
	}
	
	public function tableName()
	{
	    return strtolower(get_class($this));
	}
	
	public function relations()
	{
		return array(
			'relation'=>array(self::HAS_MANY,'Article_category_relation','article_id'),
			'tag_relation'=>array(self::HAS_MANY,'Article_tag_relation','article_id'),
		);
	}
	
	public function afterSave()
	{
//		if(!$bak_article = Article_bak::model()->findByPk($this->id))
//			$bak_article = new Article_bak();
//		$bak_article->id = $this->id;
//		$bak_article->url_key = $this->url_key;
//		$bak_article->title = $this->title;
//		$bak_article->en_title = $this->en_title;
//		$bak_article->content = $this->content;
//		$bak_article->en_content = $this->en_content;
//		$bak_article->create_time = $this->create_time;
//		$bak_article->update_time = $this->update_time;
//		$bak_article->is_recommend = $this->is_recommend;
//		$bak_article->color = $this->color;
//		$bak_article->visit = $this->visit;
//		$bak_article->cached = $this->cached;
//		$bak_article->save();
	}
}